#!/bin/bash

# on Windows, docker run needs to be prefixed by winpty
if [ "$OSTYPE" == "msys" ]; then
	DOCKER="winpty docker"
else
	DOCKER=${DOCKER:-docker}
fi

$DOCKER stop indy-demo-postgres &> /dev/null \
	&& echo "Stopped previous postgres container" || true

$DOCKER run --rm -ti --name indy-demo-postgres \
	-e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 \
	-d postgres:11 \
	-c 'log_statement=all' -c 'logging_collector=on' -c 'log_destination=stderr' \
	-c 'log_connections=on'
